# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Brandon Boese <brandonboese@protonmail.com>
pkgname=yaru-common
_pkgname=yaru
pkgver=23.10.0
_minorpkgver=-0ubuntu2
pkgrel=0
pkgdesc="Ubuntu community theme"
options="!check" # No testsuite
url="https://community.ubuntu.com/c/desktop/theme-refresh"
arch="noarch"
license="GPL-3.0-or-later AND CC-BY-SA-4.0"
makedepends="
	bash
	coreutils
	dbus
	glib-dev
	meson
	sassc
	xvfb-run
	"
subpackages="
	$_pkgname-icon-theme-bark:_icon_theme_bark
	$_pkgname-icon-theme-blue:_icon_theme_blue
	$_pkgname-icon-theme-magenta:_icon_theme_magenta
	$_pkgname-icon-theme-mate:_icon_theme_mate
	$_pkgname-icon-theme-olive:_icon_theme_olive
	$_pkgname-icon-theme-prussiangreen:_icon_theme_prussiangreen
	$_pkgname-icon-theme-purple:_icon_theme_purple
	$_pkgname-icon-theme-red:_icon_theme_red
	$_pkgname-icon-theme-sage:_icon_theme_sage
	$_pkgname-icon-theme-viridian:_icon_theme_viridian
	$_pkgname-icon-theme:_icon_theme
	$_pkgname-schemas:_schemas
	$_pkgname-shell:_shell
	$_pkgname-sounds:_sounds
	$_pkgname-theme-bark:_theme_bark
	$_pkgname-theme-blue:_theme_blue
	$_pkgname-theme-hdpi:_theme_hdpi
	$_pkgname-theme-magenta:_theme_magenta
	$_pkgname-theme-mate:_theme_mate
	$_pkgname-theme-olive:_theme_olive
	$_pkgname-theme-prussiangreen:_theme_prussiangreen
	$_pkgname-theme-purple:_theme_purple
	$_pkgname-theme-red:_theme_red
	$_pkgname-theme-sage:_theme_sage
	$_pkgname-theme-viridian:_theme_viridian
	$_pkgname-theme:_theme
	"
source="$_pkgname-$pkgver.tar.gz::https://github.com/ubuntu/yaru/archive/$pkgver$_minorpkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver$_minorpkgver"

build() {
	abuild-meson \
		-Dmate=true \
		-Dmate-dark=true \
		-Dubuntu-unity=true \
		-Dxfwm4=true \
		-Dcinnamon=true \
		-Dcinnamon-dark=true \
		-Dcinnamon-shell=true \
		. output
	meson compile -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

_icon_theme_bark() {
	depends=""
	pkgdesc="Bark variant of Yaru icon theme"

	mkdir -p "$subpkgdir"/usr/share/icons
	mv "$pkgdir"/usr/share/icons/Yaru-bark "$subpkgdir"/usr/share/icons
	mv "$pkgdir"/usr/share/icons/Yaru-bark-dark "$subpkgdir"/usr/share/icons
}

_theme_bark() {
	depends="yaru-common"
	pkgdesc="Bark variant of Yaru theme"

	mkdir -p "$subpkgdir"/usr/share/themes
	mv "$pkgdir"/usr/share/themes/Yaru-bark \
		"$subpkgdir"/usr/share/themes/Yaru-bark
	mv "$pkgdir"/usr/share/themes/Yaru-bark-dark \
		"$subpkgdir"/usr/share/themes/Yaru-bark-dark
}

_icon_theme_blue() {
	depends=""
	pkgdesc="Blue variant of Yaru icon theme"

	mkdir -p "$subpkgdir"/usr/share/icons
	mv "$pkgdir"/usr/share/icons/Yaru-blue "$subpkgdir"/usr/share/icons
	mv "$pkgdir"/usr/share/icons/Yaru-blue-dark "$subpkgdir"/usr/share/icons
}

_theme_blue() {
	depends="yaru-common"
	pkgdesc="Blue variant of Yaru theme"

	mkdir -p "$subpkgdir"/usr/share/themes
	mv "$pkgdir"/usr/share/themes/Yaru-blue \
		"$subpkgdir"/usr/share/themes/Yaru-blue
	mv "$pkgdir"/usr/share/themes/Yaru-blue-dark \
		"$subpkgdir"/usr/share/themes/Yaru-blue-dark
}

_theme_hdpi() {
	depends="yaru-common"
	pkgdesc="Hdpi variant of Yaru theme"

	mkdir -p "$subpkgdir"/usr/share/themes
	mv "$pkgdir"/usr/share/themes/Yaru-hdpi \
		"$subpkgdir"/usr/share/themes/Yaru-hdpi
	mv "$pkgdir"/usr/share/themes/Yaru-dark-hdpi \
		"$subpkgdir"/usr/share/themes/Yaru-dark-hdpi
	mv "$pkgdir"/usr/share/themes/Yaru-xhdpi \
		"$subpkgdir"/usr/share/themes/Yaru-xhdpi
	mv "$pkgdir"/usr/share/themes/Yaru-dark-xhdpi \
		"$subpkgdir"/usr/share/themes/Yaru-dark-xhdpi
}

_icon_theme_magenta() {
	depends=""
	pkgdesc="Magenta variant of Yaru icon theme"

	mkdir -p "$subpkgdir"/usr/share/icons
	mv "$pkgdir"/usr/share/icons/Yaru-magenta "$subpkgdir"/usr/share/icons
	mv "$pkgdir"/usr/share/icons/Yaru-magenta-dark "$subpkgdir"/usr/share/icons
}

_theme_magenta() {
	depends="yaru-common"
	pkgdesc="Magenta variant of Yaru theme"

	mkdir -p "$subpkgdir"/usr/share/themes
	mv "$pkgdir"/usr/share/themes/Yaru-magenta \
		"$subpkgdir"/usr/share/themes/Yaru-magenta
	mv "$pkgdir"/usr/share/themes/Yaru-magenta-dark \
		"$subpkgdir"/usr/share/themes/Yaru-magenta-dark
}

_icon_theme_mate() {
	depends=""
	pkgdesc="Mate variant of Yaru icon theme"

	mkdir -p "$subpkgdir"/usr/share/icons
	mv "$pkgdir"/usr/share/icons/Yaru-mate "$subpkgdir"/usr/share/icons
	mv "$pkgdir"/usr/share/icons/Yaru-mate-dark "$subpkgdir"/usr/share/icons
}

_theme_mate() {
	depends="yaru-common"
	pkgdesc="Mate variant of Yaru theme"

	mkdir -p "$subpkgdir"/usr/share/themes
	mv "$pkgdir"/usr/share/themes/Yaru-mate \
		"$subpkgdir"/usr/share/themes/Yaru-mate
	mv "$pkgdir"/usr/share/themes/Yaru-mate-dark \
		"$subpkgdir"/usr/share/themes/Yaru-mate-dark
}

_icon_theme_olive() {
	depends=""
	pkgdesc="Olive variant of Yaru icon theme"

	mkdir -p "$subpkgdir"/usr/share/icons
	mv "$pkgdir"/usr/share/icons/Yaru-olive "$subpkgdir"/usr/share/icons
	mv "$pkgdir"/usr/share/icons/Yaru-olive-dark "$subpkgdir"/usr/share/icons
}

_theme_olive() {
	depends="yaru-common"
	pkgdesc="Olive variant of Yaru theme"

	mkdir -p "$subpkgdir"/usr/share/themes
	mv "$pkgdir"/usr/share/themes/Yaru-olive \
		"$subpkgdir"/usr/share/themes/Yaru-olive
	mv "$pkgdir"/usr/share/themes/Yaru-olive-dark \
		"$subpkgdir"/usr/share/themes/Yaru-olive-dark
}

_icon_theme_prussiangreen() {
	depends=""
	pkgdesc="Prussian green variant of Yaru icon theme"

	mkdir -p "$subpkgdir"/usr/share/icons
	mv "$pkgdir"/usr/share/icons/Yaru-prussiangreen "$subpkgdir"/usr/share/icons
	mv "$pkgdir"/usr/share/icons/Yaru-prussiangreen-dark "$subpkgdir"/usr/share/icons
}

_theme_prussiangreen() {
	depends="yaru-common"
	pkgdesc="Prussian green variant of Yaru theme"

	mkdir -p "$subpkgdir"/usr/share/themes
	mv "$pkgdir"/usr/share/themes/Yaru-prussiangreen \
		"$subpkgdir"/usr/share/themes/Yaru-prussiangreen
	mv "$pkgdir"/usr/share/themes/Yaru-prussiangreen-dark \
		"$subpkgdir"/usr/share/themes/Yaru-prussiangreen-dark
}

_icon_theme_purple() {
	depends=""
	pkgdesc="Purple variant of Yaru icon theme"

	mkdir -p "$subpkgdir"/usr/share/icons
	mv "$pkgdir"/usr/share/icons/Yaru-purple "$subpkgdir"/usr/share/icons
	mv "$pkgdir"/usr/share/icons/Yaru-purple-dark "$subpkgdir"/usr/share/icons
}

_theme_purple() {
	depends="yaru-common"
	pkgdesc="Purple variant of Yaru theme"

	mkdir -p "$subpkgdir"/usr/share/themes
	mv "$pkgdir"/usr/share/themes/Yaru-purple \
		"$subpkgdir"/usr/share/themes/Yaru-purple
	mv "$pkgdir"/usr/share/themes/Yaru-purple-dark \
		"$subpkgdir"/usr/share/themes/Yaru-purple-dark
}

_icon_theme_red() {
	depends=""
	pkgdesc="Red variant of Yaru icon theme"

	mkdir -p "$subpkgdir"/usr/share/icons
	mv "$pkgdir"/usr/share/icons/Yaru-red "$subpkgdir"/usr/share/icons
	mv "$pkgdir"/usr/share/icons/Yaru-red-dark "$subpkgdir"/usr/share/icons
}

_theme_red() {
	depends="yaru-common"
	pkgdesc="Red variant of Yaru theme"

	mkdir -p "$subpkgdir"/usr/share/themes
	mv "$pkgdir"/usr/share/themes/Yaru-red \
		"$subpkgdir"/usr/share/themes/Yaru-red
	mv "$pkgdir"/usr/share/themes/Yaru-red-dark \
		"$subpkgdir"/usr/share/themes/Yaru-red-dark
}

_icon_theme_sage() {
	depends=""
	pkgdesc="Sage variant of Yaru icon theme"

	mkdir -p "$subpkgdir"/usr/share/icons
	mv "$pkgdir"/usr/share/icons/Yaru-sage "$subpkgdir"/usr/share/icons
	mv "$pkgdir"/usr/share/icons/Yaru-sage-dark "$subpkgdir"/usr/share/icons
}

_theme_sage() {
	depends="yaru-common"
	pkgdesc="Sage variant of Yaru theme"

	mkdir -p "$subpkgdir"/usr/share/themes
	mv "$pkgdir"/usr/share/themes/Yaru-sage \
		"$subpkgdir"/usr/share/themes/Yaru-sage
	mv "$pkgdir"/usr/share/themes/Yaru-sage-dark \
		"$subpkgdir"/usr/share/themes/Yaru-sage-dark
}

_icon_theme_viridian() {
	depends=""
	pkgdesc="Viridian variant of Yaru icon theme"

	mkdir -p "$subpkgdir"/usr/share/icons
	mv "$pkgdir"/usr/share/icons/Yaru-viridian "$subpkgdir"/usr/share/icons
	mv "$pkgdir"/usr/share/icons/Yaru-viridian-dark "$subpkgdir"/usr/share/icons
}

_theme_viridian() {
	depends="yaru-common"
	pkgdesc="Viridian variant of Yaru theme"

	mkdir -p "$subpkgdir"/usr/share/themes
	mv "$pkgdir"/usr/share/themes/Yaru-viridian \
		"$subpkgdir"/usr/share/themes/Yaru-viridian
	mv "$pkgdir"/usr/share/themes/Yaru-viridian-dark \
		"$subpkgdir"/usr/share/themes/Yaru-viridian-dark
}

_schemas() {
	depends="yaru-common yaru-icon-theme yaru-theme"
	pkgdesc="Schema files for Yaru theme"

	mkdir -p "$subpkgdir"/usr/share
	mv "$pkgdir"/usr/share/glib-2.0 "$subpkgdir"/usr/share
}

_shell() {
	depends="yaru-common yaru-icon-theme yaru-schemas yaru-sounds yaru-theme"
	pkgdesc="Yaru shell theme for the GNOME Desktop Environment"

	install_if="yaru-common=$pkgver-r$pkgrel gnome-shell"

	mkdir -p "$subpkgdir"/usr/share
	mv "$pkgdir"/usr/share/gnome-shell "$subpkgdir"/usr/share

	mv "$pkgdir"/usr/share/wayland-sessions \
		"$pkgdir"/usr/share/xsessions \
		"$subpkgdir"/usr/share
}

_sounds() {
	depends=""
	pkgdesc="Yaru sound resources"

	mkdir -p "$subpkgdir"/usr/share
	mv "$pkgdir"/usr/share/sounds "$subpkgdir"/usr/share
}

_icon_theme() {
	depends=""
	pkgdesc="Yaru icon theme"

	mkdir -p "$subpkgdir"/usr/share
	mv "$pkgdir"/usr/share/icons "$subpkgdir"/usr/share
}

_theme() {
	depends="yaru-common"
	pkgdesc="Yaru, the Ubuntu community theme"

	mkdir -p "$subpkgdir"/usr/share
	mv "$pkgdir"/usr/share/themes \
		"$subpkgdir"/usr/share
}

sha512sums="
4047df97026d79f4fcd541a0afea6c39294956761c9face9d5506cd188b05b52c6d627d2e25226bce09a6dcb682f4e1aff7411dc69ae4770c8cd9c19783f30de  yaru-23.10.0.tar.gz
"
